<template>
<view class="queryResult">
    <view class="title">低保户基本信息</view>
    <div class="card_info">
        <view>
            <view class="li" v-if="MASTER.CLASS1">保障类型：{{MASTER.CLASS1}}</view>
            <view class="li" v-if="MASTER.LM_NAME">户主姓名：{{MASTER.LM_NAME}}</view>
            <view class="li" v-if="MASTER.CLASS2">救助类别：{{MASTER.CLASS2}}</view>
            <view class="li" v-if="MASTER.LM_RS">保障人口：{{MASTER.LM_RS}}</view>
            <view class="li" v-if="MASTER.MONEY_WAGE">测算就业收入：{{MASTER.MONEY_WAGE}}元/月</view>
            <view class="li" v-if="MASTER.MONEY_MANAGER">测算经营性收入：{{MASTER.MONEY_MANAGER}}元/月</view>
            <view class="li" v-if="MASTER.MONEY_PROPERTY">测算财产性收入：{{MASTER.MONEY_PROPERTY}}元/月</view>
            <view class="li" v-if="MASTER.MONEY_TRANSFER">测算转移性收入：{{MASTER.MONEY_TRANSFER}}元/月</view>
            <view class="li" v-if="MASTER.COST_PREMIUM">测算保险费收入：{{MASTER.COST_PREMIUM}}元/月</view>
            <view class="li" v-if="MASTER.AMOUNT_INCOME">家庭总收入：{{MASTER.AMOUNT_INCOME}}元/月</view>
            <view class="li" v-if="MASTER.MONEY_SUPPORT">测算赡养费：{{MASTER.MONEY_SUPPORT}}元/月</view>
            <view class="li" v-if="MASTER.COST_TEACH">测算教育支出：{{MASTER.COST_TEACH}}元/月</view>
            <view class="li" v-if="MASTER.COST_NURSING">测算护理支出：{{MASTER.COST_NURSING}}元/月</view>
            <view class="li" v-if="MASTER.COST_CARE">测算照管支出：{{MASTER.COST_CARE}}元/月</view>
            <view class="li" v-if="MASTER.COST_MEDICAL">测算医疗费支出：{{MASTER.COST_MEDICAL}}元/月</view>
            <view class="li" v-if="MASTER.COST_OTHER">测算其它支出：{{MASTER.COST_OTHER}}元/月</view>
            <view class="li red">保障金额：{{MASTER.AMOUNT_MONEY}}元/月</view>
        </view>
    </div>
    <view class="container">
        <view class="title_validation">{{formatDate(new Date(STEP1_BDATE),'yyyy年MM月')}}月低保申请工作</view>
        <view class="tips" v-if="isok">请于{{formatDate(new Date(STEP1_BDATE),'yyyy年MM月dd日')}}~{{formatDate(new Date(STEP1_EDATE),'yyyy年MM月dd日')}}<br>完成人脸验证工作</view>
        <view class="tips" v-else>当前时间不在人脸验证范围内</view>
        <view class="user_list" v-if="isok">
            <view class="li" v-for="(item,index) in DETAIL" :key="index">
                <image :src="$host+item.LD_IMG" class="right_img" @click="uploadpictures(item)"></image>
                <view class="name">{{item.LD_NAME}}</view>
                <view class="state">{{item.CK}}</view>
            </view>
        </view>
    </view>
</view>
</template>

<script>
import { formatDate } from '@/utils/date.js'
export default {
    data() {
        return {
            isok: true,
            STEP1_BDATE: '',
            STEP1_EDATE: '',
            location:{},
            isWindows:false,
            $host:this.$host,
            active: 0,
            DETAIL:[],
            MASTER:{}
        }
    },
    onLoad(options) {
        let that = this;
        uni.getSystemInfo({
            success: function (res) {
                if (res.platform == 'windows') {
                    that.isWindows = true
                }
            }
        });
        uni.getStorage({
            key: 'location',
            success: function (res) {
                that.location = res.data
            }
        });
        this.$http.get('checknow').then(res => {
            this.STEP1_BDATE = res.data.STEP1_BDATE.replace(/-/g, '/')
            this.STEP1_EDATE = res.data.STEP1_EDATE.replace(/-/g, '/')
            if(res.data.code != 0){
            this.isok = false
            }
        })
        // console.log(JSON.parse(decodeURIComponent(options.data)))
        this.MASTER = JSON.parse(decodeURIComponent(options.data)).MASTER
        this.DETAIL = JSON.parse(decodeURIComponent(options.data)).DETAIL
    },
    methods: {
        formatDate,
        // 验证人脸信息
        uploadpictures(item) {
            if (this.isWindows) {
                uni.showModal({
                    title: '提示',
                    showCancel: false,
                    content: '不支持电脑上传图片，请用手机操作'
                });
                return false
            }
            if(item.CK == '验证成功'){
                return false
            }
            let that = this;
            console.log(that.location)
            uni.chooseImage({
                count: 1,
                sizeType: ['compressed'],
                sourceType: ['camera'],
                success: function (self) {
                    that.$http.upload('checkface', {filePath: self.tempFilePaths[0], name: encodeURI('filePath'),formData:{
                        "LM_GUID":item.LM_GUID,
                        "LD_ID":item.LD_ID,
                        "GPS_latitude":that.location.latitude,
                        "GPS_longitude":that.location.longitude,
                        "GPS_address":that.location.address
                    }
                    }).then(res => {
						console.log(JSON.parse(res))
                        if (JSON.parse(res).data.code == 0) {
                            uni.showToast({
                                title: '当前成员验证完成',
                                duration: 2000
                            });
                            item.CK = '验证成功'
                        } else {
							if (JSON.parse(res).data.code == 1) {
							    uni.showModal({
							        title: '提示', 
							        showCancel: false,
							        content: "您及保障人员都已经验证完成；"+ JSON.parse(res).data.masterver.STEP2_MES+ "请等待上级进一步核实。",
									success: function (res) {
									    if (res.confirm) {
									        uni.navigateBack({
									            delta: 2
									        });
									    }
									}
							    });
							} else {
								uni.showModal({
								    title: '提示', 
								    showCancel: false,
								    content: JSON.parse(res).data.message
								});
							}
                        }
                    })
                }
            })
        },
    }
  }
</script>

<style lang="scss" scoped>
.container {
  width: 100%;
  box-sizing: border-box;
  display: block;
  text-align: center;
  color: #101010;
  .title_validation{
    font-size: 40upx;
    font-weight: 500;
    display: block;
    padding: 40upx 0 20upx 0;
    text-align: center;
  }
  .tips{
    color: #E51C23;
    font-size: 28upx;
  }
  .user_list{
    padding: 20rpx;
    text-align: left;
    box-sizing: border-box;
    font-size: 28upx;
    color: #101010;
    .li{
        text-align: center;
        width: 50%;
        display: inline-block;
        image{
            width: 200rpx;
            height: 250rpx;
        }
        text{
            // text-align: center;
            display: block;
        }
    }
  }
}
.queryResult{
    .title{
        font-size: 28upx;
        color: #101010;
        height: 94upx;
        line-height: 94upx;
        width: 100%;
        padding: 20upx;
        background-color: #F0EEEE;
    }
    .steps{padding: 20upx;}
    .card_info{
        font-size: 26upx;
        color: #101010;
        padding: 28upx;
        position: relative;
        display: flex;
        justify-content: space-between;
        .li{
            display: inline-block;
            width: 50%;
            line-height: 60upx;
            &.red{
                color: #E51C23;
            }
        }
        .user_pic{
            width: 129upx;
            height: 128upx;
        }
    }
}
</style>